﻿namespace GCC.Container.Abstracts
{
    /// <summary>
    /// 容器日志抽象
    /// </summary>
    /// <typeparam name="T"></typeparam>
    public abstract class AbsGCCLogger<T> where T : class
    {
        /// <summary>
        /// 实际的日志实例
        /// </summary>
        private readonly AbsGCCLogger _loggerInstance;

        /// <summary>
        /// 构造函数
        /// </summary>
        /// <param name="logger">日志具体实例</param>
        protected AbsGCCLogger(AbsGCCLogger logger)
        {
            _loggerInstance = logger;
        }


        /// <summary>
        /// 记录追踪日志
        /// </summary>        
        /// <param name="text">文本</param>
        /// <param name="eventID">事件ID</param>
        /// <param name="exception">异常</param>
        public void Trace(string text, string? eventID = null, Exception? exception = null)
        {
            this._loggerInstance.Log(LogLevelEnum.Trace, text, eventID, exception);
        }



        /// <summary>
        /// 记录调试日志
        /// </summary>        
        /// <param name="text">文本</param>
        /// <param name="eventID">事件ID</param>
        /// <param name="exception">异常</param>
        public void Debug(string text, string? eventID = null, Exception? exception = null)
        {
            this._loggerInstance.Log(LogLevelEnum.Debug, text, eventID, exception);
        }
        /// <summary>
        /// 记录信息日志
        /// </summary>        
        /// <param name="text">文本</param>
        /// <param name="eventID">事件ID</param>
        /// <param name="exception">异常</param>
        public void Information(string text, string? eventID = null, Exception? exception = null)
        {
            this._loggerInstance.Log(LogLevelEnum.Information, text, eventID, exception);
        }
        /// <summary>
        /// 记录警告日志
        /// </summary>        
        /// <param name="text">文本</param>
        /// <param name="eventID">事件ID</param>
        /// <param name="exception">异常</param>
        public void Warning(string text, string? eventID = null, Exception? exception = null)
        {
            this._loggerInstance.Log(LogLevelEnum.Warning, text, eventID, exception);
        }

        /// <summary>
        /// 记录错误日志
        /// </summary>        
        /// <param name="text">文本</param>
        /// <param name="eventID">事件ID</param>
        /// <param name="exception">异常</param>
        public void Error(string text, string? eventID = null, Exception? exception = null)
        {
            this._loggerInstance.Log(LogLevelEnum.Error, text, eventID, exception);
        }


        /// <summary>
        /// 记录危险日志
        /// </summary>        
        /// <param name="text">文本</param>
        /// <param name="eventID">事件ID</param>
        /// <param name="exception">异常</param>
        public void Critical(string text, string? eventID = null, Exception? exception = null)
        {
            this._loggerInstance.Log(LogLevelEnum.Critical, text, eventID, exception);
        }
    }
}
